package com.jeesite.modules.sys.utils;

import com.jeesite.modules.sys.entity.Office;
import org.apache.shiro.session.Session;

/**
 * @description:
 * @author: ciye
 * @date: 2022/3/8 17:06
 */
public class OfficeUtil {
    /**
     * 返回当前用户的机构信息
     * @return
     */
    public static Office getCurrentOffice() {
        Session session = UserUtils.getSession();
        Office office = new Office();
        if (session.getAttribute("officeCode") != null) {
            Office officeCode = EmpUtils.getOffice(String.valueOf(session.getAttribute("officeCode")));
            if (officeCode!=null){
                return officeCode;
            }
            office.setOfficeCode(session.getAttribute("officeCode").toString());
            office.setOfficeName(session.getAttribute("officeName").toString());
        } else {
            office = EmpUtils.getEmployee().getOffice();
        }
        return office;
    }
}
